/**
 * Created by geo on 08-26.
 */
function drawTextAlongArc(context, str, centerX, centerY, radius, angle) {
    var len = str.length,
        s;
    context.save();
    context.translate(centerX, centerY);
    context.rotate(-1 * angle / 2);
    context.rotate(-1 * (angle / len) / 2);
    for (var n = 0; n < len; n++) {
        context.rotate(angle / len);
        context.save();
        context.translate(0, -1 * radius);
        s = str[n];
        context.fillText(s, 0, 0);
        context.restore();
    }
    context.restore();
}

function drawTextAlongArc2(context, text, x, y, radius, startRotation, range) {
    var numRadsPerLetter = range / text.length;
    context.save();
    context.translate(x, y);
    context.rotate(startRotation);

    for (var i = 0; i < text.length; i++) {
        context.save();
        context.rotate(i * numRadsPerLetter);

        context.fillText(text[i], 0, -radius);
        context.restore();
    }
    context.restore();
}

function shuffle(array) {
    var counter = array.length;

    // While there are elements in the array
    while (counter > 0) {
        // Pick a random index
        var index = Math.floor(Math.random() * counter);

        // Decrease counter by 1
        counter--;

        // And swap the last element with it
        var temp = array[counter];
        array[counter] = array[index];
        array[index] = temp;
    }

    return array;
}


function getUrlParameter(sParam) {
    var sPageURL = decodeURIComponent(window.location.search.substring(1)),
        sURLVariables = sPageURL.split('&'),
        sParameterName,
        i;

    for (i = 0; i < sURLVariables.length; i++) {
        sParameterName = sURLVariables[i].split('=');

        if (sParameterName[0] === sParam) {
            return sParameterName[1] === undefined ? true : sParameterName[1];
        }
    }
}


function rnd(n, m) {
		var random = Math.floor(Math.random() * (m - n + 1) + n);
		return random;
		
	}
